{% extends "base_for_backbone.html" %}
{% load seahub_tags avatar_tags group_avatar_tags i18n %}
{% load staticfiles %}

{% block sub_title %}{% trans "Libraries" %} - {% endblock %}
{% block extra_style %}
<style type="text/css">
html,body {
    height:100%;
    overflow:hidden;
}
</style>
{% endblock %}

{% block extra_script %}
<script type="text/template" id="my-own-repos-tmpl">
<div class="cur-view-main"> {# .cur-view-main is only for view with side panel #}
    <div class="cur-view-path">
        <h3>{% trans "My Libraries" %}</h3>
    </div>
    <div class="cur-view-main-con">
        <table class="hide">
            <thead></thead>
            <tbody></tbody>
        </table>
        <div class="empty-tips hide">
            <h2 class="alc">{% trans "You have not created any libraries" %}</h2>
            <p>{% trans "You can create a library to organize your files. For example, you can create one for each of your projects. Each library can be synchronized and shared separately." %}</p>
        </div>
        <span class="loading-icon loading-tip"></span>
        <p class="error error-tip hide"></p>
    </div>
</div>
{# <div class="cur-view-side"></div> #}
</script>

<script type="text/template" id="my-deleted-repos-tmpl">
<div class="cur-view-path cur-view-path-path">
    <a href="#my-libs/" class="normal">{% trans "My Libraries" %}</a>
    <span class="path-split">/</span>
    <span>{% trans "Deleted Libraries" %}</span>
</div>
<div class="cur-view-main-con">
    <p class="tip">{% blocktrans %}Tip: libraries deleted {{ trash_repos_expire_days }} days ago will be cleaned automatically.{% endblocktrans %}</p>
    <table class="my-deleted-repos-table hide">
        <thead></thead>
        <tbody></tbody>
    </table>
    <div class="empty-tips hide">
        <h2 class="alc">{% trans "No deleted libraries." %}</h2>
    </div>
    <span class="loading-icon loading-tip"></span>
    <p class="error error-tip hide"></p>
</div>
</script>


<script type="text/template" id="repos-shared-to-me-tmpl">
<div class="cur-view-path">
    <h3>{% trans "Shared with me" %}</h3>
</div>

<div class="cur-view-main-con">
    <span class="loading-icon loading-tip"></span>
    <table class="hide">
        <thead></thead>
        <tbody></tbody>
    </table>
    <div class="empty-tips hide">
        <h2 class="alc">{% trans "No libraries have been shared with you" %}</h2>
        <p>{% blocktrans %}No libraries have been shared directly with you. You can find more shared libraries at "Shared with groups".{% endblocktrans %}</p>
    </div>
    <p class="error error-tip hide"></p>
</div>
</script>

<script type="text/template" id="organization-repos-tmpl">
<div class="cur-view-path">
    <h3>{% trans "Shared with all" %}</h3>
</div>

<div class="cur-view-main-con">
    <span class="loading-icon loading-tip"></span>
    <table class="repo-list hide">
        <thead></thead>
        <tbody></tbody>
    </table>
    <div class="empty-tips hide">
        <h2 class="alc">{% trans "No public libraries" %}</h2>
        <p>{% blocktrans %}You can create a public library by clicking the "New Library" button, others can view and download this library.{% endblocktrans %}</p>
    </div>
    <p class="error error-tip hide"></p>
</div>
</script>

<script type="text/template" id="groups-tmpl">
<div class="cur-view-main">
<div class="cur-view-path">
    <h3>{% trans "My Groups" %}</h3>
</div>
<div class="cur-view-main-con">
    <div id="group-list" class="hide"></div>
    <div class="empty-tips hide">
        <h2 class="alc">{% trans "You are not in any groups" %}</h2>
        {% if user.permissions.can_add_group %}
        <p>{% blocktrans %}Groups allow multiple people to collaborate on libraries. You can create a group by clicking the "New Group" button.{% endblocktrans %}</p>
        {% else %}
        <p>{% trans "Groups allow multiple people to collaborate on libraries. Groups you join will be listed here." %}</p>
        {% endif %}
    </div>
    <span class="loading-icon loading-tip"></span>
    <p class="error error-tip hide"></p>
</div>
</div>
</script>

<script type="text/template" id="group-tmpl">
<div class="cur-view-main">
    <div class="cur-view-path" id="group-path">
        <div class="group-path cur-view-path-path">
        </div>
        <div class="group-toolbar-2">
        </div>
    </div>
    <div class="cur-view-main-con" id="group-repos">
        <span class="loading-icon loading-tip"></span>
        <table class="hide">
            <thead></thead>
            <tbody></tbody>
        </table>
        <div class="empty-tips common-group-empty-tips hide">
            <h2 class="alc">{% trans "No library is shared to this group" %}</h2>
            <p>{% blocktrans %}You can share libraries by clicking the "New Library" button above or the "Share" icon on your libraries list.{% endblocktrans %}</p>
            <p>{% trans "Libraries shared as writable can be downloaded and synced by other group members. Read only libraries can only be downloaded, updates by others will not be uploaded." %}</p>
        </div>
        <div class="empty-tips address-book-group-empty-tips-for-member hide">
            <h2 class="alc">{% trans "No libraries" %}</h2>
        </div>
        <div class="empty-tips address-book-group-empty-tips-for-admin hide">
            <h2 class="alc">{% trans "No libraries" %}</h2>
            <p>{% blocktrans %}You can create libraries by clicking the "New Library" button above.{% endblocktrans %}</p>
        </div>
        <p class="error error-tip hide"></p>
    </div>
</div>
</script>

<script type="text/template" id="starred-file-tmpl">
<div class="cur-view-path">
    <h3>{% trans "Favorites" %}</h3>
</div>
<div class="cur-view-main-con">
    <table class="hide">
        <thead></thead>
        <tbody></tbody>
    </table>
    <span class="loading-icon loading-tip"></span>
    <div class="empty-tips hide">
        <h2 class="alc">{% trans "You don't have any starred files yet" %}</h2>
        <p>{% blocktrans %}You can mark files as important by clicking the "Star" button on the file viewing page. Starred files will be listed here.{% endblocktrans %}</p>
    </div>
</div>
</script>

<script type="text/template" id="activities-tmpl">
<div class="cur-view-path">
    <h3>{% trans "Activities" %}</h3>
</div>
<div class="cur-view-main-con">
    <div id="activities-body" class="hide"></div>
    <span class="loading-icon loading-tip"></span>
    <button id="activities-more" class="full-width-btn hide">{% trans 'More' %}</button>
</div>
</script>

<script type="text/template" id="devices-tmpl">
<div class="cur-view-path">
    <h3>{% trans "Linked Devices" %}</h3>
</div>
<div class="cur-view-main-con">
    <table class="hide">
        <thead>
            <tr>
                <th width="13%">{% trans "Platform" %}</th>
                <th width="30%">{% trans "Device Name" %}</th>
                <th width="30%">{% trans "IP" %}</th>
                <th width="17%">{% trans "Last Access" %}</th>
                <th width="10%"></th>
            </tr>
        </thead>
        <tbody></tbody>
    </table>
    <span class="loading-icon loading-tip"></span>
    <div class="empty-tips hide">
        <h2 class="alc">{% trans "You do not have connected devices" %}</h2>
        <p>{% trans "Your clients (Desktop/Android/iOS) will be listed here." %}</p>
    </div>
</div>
</script>

<script type="text/template" id="dir-view-tmpl">
<div class="cur-view-main">
    <div class="cur-view-path" id="dir-view-path">
        <div class="dir-path cur-view-path-path"></div>
        <div class="dir-toolbar-2"></div>
    </div>
    <div class="cur-view-main-con">
        <span class="loading-icon loading-tip"></span>
        <div class="js-dir-content hide">
            <table class="repo-file-list hide">
                <thead></thead>
                <tbody></tbody>
            </table>
            <ul class="grid-view hide">
            </ul>
        </div>
        <p class="error hide"></p>
    </div>
</div>
{# <div class="cur-view-side"></div> #}
</script>

{% include "js/lib-op-popups.html" %}

<script type="text/javascript">
app["pageOptions"] = {
    site_root: "{{ SITE_ROOT }}",
    csrfToken: "{{ csrf_token }}",
    groups: (function () {
        var groups = [];
        {% for group in joined_groups %}
        groups.push({'name': '{{group.group_name|escapejs}}', 'id': '{{group.id}}'});
        {% endfor %}
        return groups;
    })(),
    joined_groups_exclude_address_book: (function () {
        var groups = [];
        {% for group in joined_groups_exclude_address_book %}
        groups.push({'name': '{{group.group_name|escapejs}}', 'id': '{{group.id}}'});
        {% endfor %}
        return groups;
    })(),
    library_templates: (function () {
        var templates = [];
        {% for template in library_templates %}
        templates.push('{{ template|escapejs }}');
        {% endfor %}
        return templates;
    })(),
    storages: (function () {
        var storages = [];
        {% for storage in storages %}
        storages.push({'storage_name': '{{storage.storage_name|escapejs}}', 'storage_id': '{{storage.storage_id|escapejs}}'});
        {% endfor %}
        return storages;
    })(),
    user_mods_available: (function () {
        var mods_available = [];
        {% for mod in request.user.mods_available %}
        mods_available.push('{{mod}}');
        {% endfor %}
        return mods_available;
    })(),
    user_mods_enabled: (function () {
        var mods_enabled = [];
        {% for mod in request.user.mods_enabled %}
        mods_enabled.push('{{mod}}');
        {% endfor %}
        return mods_enabled;
    })(),
    username: "{{request.user.username|escapejs}}",
    name: "{{request.user.username|email2nickname|escapejs}}",
    contact_email: "{{ request.user.username|email2contact_email|escapejs }}",
    events_enabled: {% if events_enabled %} true {% else %} false {% endif %},
    can_add_repo: {% if user.permissions.can_add_repo %} true {% else %} false {% endif %},
    can_generate_share_link: {% if user.permissions.can_generate_share_link %} true {% else %} false {% endif %},
    can_generate_upload_link: {% if user.permissions.can_generate_upload_link %} true {% else %} false {% endif %},
    is_staff: {% if request.user.is_staff %} true {% else %} false {% endif %},
    repo_password_min_length: {{ repo_password_min_length }},
    share_link_password_min_length: {{ share_link_password_min_length }},
    share_link_expire_days_min: {{ share_link_expire_days_min }},
    share_link_expire_days_max: {{ share_link_expire_days_max }},
    share_link_expire_days_default: {{ share_link_expire_days_default }},
    guide_enabled: {% if guide_enabled %} true {% else %} false {% endif %},
    enable_wiki: {% if enable_wiki %} true {% else %} false {% endif %},
    enable_upload_folder: {% if enable_upload_folder %} true {% else %} false {% endif %},
    enable_resumable_fileupload: {% if enable_resumable_fileupload %} true {% else %} false {% endif %},
    resumable_upload_file_block_size: {{ resumable_upload_file_block_size }},
    max_number_of_files_for_fileupload: {{ max_number_of_files_for_fileupload }},
    enable_thumbnail: {% if enable_thumbnail %} true {% else %} false {% endif %},
    thumbnail_default_size: {{ thumbnail_default_size }},
    thumbnail_size_for_grid: {{ thumbnail_size_for_grid }},
    thumbnail_size_for_original: {{ thumbnail_size_for_original }},
    language_code: "{{ LANGUAGE_CODE }}",
    enable_encrypted_library: {% if enable_encrypted_library %} true {% else %} false {% endif %},
    enable_repo_history_setting: {% if enable_repo_history_setting %} true {% else %} false {% endif %},
    max_upload_file_size: {% if max_upload_file_size %} {{ max_upload_file_size }} {% else %} '' {% endif %},
    folder_perm_enabled: {% if folder_perm_enabled %} true {% else %} false {% endif %},
    is_pro: {% if is_pro %} true {% else %} false {% endif %},
    file_audit_enabled: {% if file_audit_enabled %} true {% else %} false {% endif %},
    enable_repo_snapshot_label: {% if enable_repo_snapshot_label %} true {% else %} false {% endif %},
    unread_notifications_request_interval: {{ unread_notifications_request_interval }},
    enable_share_to_all_groups: {% if enable_share_to_all_groups %} true {% else %} false {% endif %},
    cur_note: {% if request.cur_note %} {'id': '{{ request.cur_note.id }}'} {% else %} null {% endif %},
    enable_group_discussion: {% if enable_group_discussion %} true {% else %} false {% endif %},
    enable_file_comment: {% if enable_file_comment %} true {% else %} false {% endif %},
    enable_office_web_app: {% if enable_office_web_app %} true {% else %} false {% endif %},
    enable_onlyoffice: {% if enable_onlyoffice %} true {% else %} false {% endif %},
    enable_repo_wiki_mode: {% if enable_repo_wiki_mode %} true {% else %} false {% endif %}
};
app.ui = {
    currentDropdown: null,
    currentPopover: null,
    currentHighlightedItem: null,
    freezeItemHightlight: false
};
</script>
{% if debug %}
<script data-main="{% static "scripts/main.js" %}" src="{% static "scripts/lib/require.js" %}"></script>
{% else %}
<script data-main="{% static "scripts/dist/main.js" %}" src="{% static "scripts/lib/require.js" %}"></script>
{% endif %}
{% endblock %}
